using MultiAgentsShared;
using static MultiAgentsClient.Service.SignalRService.SignalRClientServiceBase;

namespace MultiAgentsClient.Presentation;

public sealed partial class LoginPage : Page
{
    private readonly IEventBus eventBus;

    public LoginPage()
    {
        InitializeComponent();
        DataContext = new BindableLoginPageModel();

        eventBus = EventBus.Instance;
    }

    private void ServerSelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        if (sender is ComboBox comboBox)
        {
            string selectedServer = (string)comboBox.SelectedItem;
            eventBus.Publish(new ConnectServerCommand(selectedServer));
        }
    }
}
